public class Demo5 {
    public static void main(String[] args) {
        Object locker = new Object();

        Thread thread1 = new Thread(() -> {
            synchronized(locker) {
                try {
                    locker.wait();
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName());
            }
        });

//        Thread thread2 = new Thread(() -> {
//            synchronized(locker) {
//                locker.notify();
//            }
//            System.out.println(Thread.currentThread().getName());
//
//        });

        synchronized(locker) {
            locker.notify();
        }
        thread1.start();
//        thread2.start();
    }
}
